<?php

function observation_user_page($account) {
  $path = drupal_get_path('module','win_observation');
  drupal_add_js($path . '/js/external/jquery-1.3.2.js');
  drupal_add_js($path . '/js/external/jquery.dataTables.js');
  drupal_add_js($path . '/js/search_results_page.js');

  drupal_add_css($path . '/css/jquery.datatable/css/demo_table.css');

  $oids = get_oids_for_user($account->uid);
  $observations = get_observation_info_for_search_results($oids);
  return show_search_results($observations);
}

function get_oids_for_user($uid) {
  $oids = array();
  
  global $user;
  
  $query = 'select id from win_observations where created_by = %d ';
  if (!($user->uid == $uid || is_user_validator())) {
    $query .= ' and id not in (select distinct observation_id from win_validation where status = 1) ';
  }
  $query .= 'order by created_date';
  $query_args = array($uid);
  $result = db_query($query, $query_args);
  if (!$result) {
    return FALSE;
  }
  else {
    while ($obj = db_fetch_object($result)) {
      $oids[] = $obj->id;
    }
  }
  
  return $oids;
}